﻿using AutoMapper;
using MediatR;
using Traceability.Commont.Domains;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;

namespace Traceability.Api.Applications.Userss
{
    public class UserLoginHander : IRequestHandler<UserLoginCommand, Resqults>
    {
        private readonly IBateRepository<Users> user;
        private readonly IMapper mapper;

        public UserLoginHander(IBateRepository<Users> user, IMapper mapper)
        {
            this.user = user;
            this.mapper = mapper;
        }

        public async Task<Resqults> Handle(UserLoginCommand request, CancellationToken cancellationToken)
        {
            Resqults res = new Resqults();
            var cou = user.GetAll().Where(x => x.UserName == request.UserName && x.Pwd == request.pwd).FirstOrDefault();
            res.Date = cou;
            return res;
        }
    }
}
